<template>
  <nav class="main-nav">
    <button class="nav-toggle" @click="toggleMenu" aria-label="Toggle navigation">
      <span></span>
      <span></span>
      <span></span>
    </button>
    <ul class="nav-list" :class="{ 'is-active': isMenuOpen }">
      <li><router-link to="/" @click="closeMenu">HOME</router-link></li>
      <li><router-link to="/news" @click="closeMenu">NEWS</router-link></li>
      <li><router-link to="/publications" @click="closeMenu">PUBLICATIONS</router-link></li>
      <li><router-link to="/research" @click="closeMenu">RESEARCH</router-link></li>
      <li><router-link to="/members" @click="closeMenu">MEMBERS</router-link></li>
      <li><router-link to="/join-us" @click="closeMenu">JOIN US</router-link></li>
    </ul>
  </nav>
</template>

<script>
export default {
  name: 'Navigation',
  data() {
    return {
      isMenuOpen: false
    }
  },
  methods: {
    toggleMenu() {
      this.isMenuOpen = !this.isMenuOpen
    },
    closeMenu() {
      this.isMenuOpen = false
    }
  }
}
</script>

<style scoped>
.main-nav {
  position: relative;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px;
}

.nav-toggle span {
  width: 28px;
  height: 3px;
  background-color: #fff;
  margin: 4px 0;
  transition: 0.3s;
}

.nav-list {
  display: flex;
  list-style: none;
  gap: 0;
  margin: 0;
  padding: 0;
  align-items: center;
}

.nav-list li {
  position: relative;
}

.nav-list a {
  color: #fff;
  font-weight: 400;
  padding: 10px 20px;
  display: block;
  transition: all 0.3s ease;
  font-size: 1.15em;
  letter-spacing: 0.5px;
}

.nav-list a:hover {
  color: #00bcd4;
  background-color: rgba(0, 188, 212, 0.1);
}

.nav-list a.router-link-active {
  color: #00bcd4;
}

@media (max-width: 1024px) {
  .main-nav {
    position: relative;
    z-index: 1001;
    width: 100%;
  }
  
  .nav-toggle {
    display: flex;
    position: relative;
    z-index: 1002;
    margin-left: auto;
  }
  
  .nav-list {
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    flex-direction: column;
    background-color: #5a5a5a;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    padding: 10px 0;
    gap: 0;
    border-radius: 0;
    display: none;
    min-width: 200px;
    width: auto;
    max-width: calc(100vw - 30px);
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    z-index: 1001;
    justify-content: flex-start;
    align-items: stretch;
  }
  
  .nav-list.is-active {
    display: flex;
  }
  
  .nav-list li {
    width: 100%;
  }
  
  .nav-list a {
    width: 100%;
    padding: 15px 20px;
    text-align: left;
    white-space: nowrap;
  }
}

@media (max-width: 768px) {
  .nav-list {
    right: 0;
    min-width: 180px;
    max-width: calc(100vw - 20px);
  }
}
</style>

